<?php
//error_reporting(E_ALL);
include "includes/session.php";
include "includes/comunes.php";
require_once("includes/paginator.class.php");
$pages = new Paginator;


//armo el Where de la consutla
$where=" 1=1 ";

if($_POST['origen']<>"" and $_POST['origen']<>0)
     $where.=" and sucursalId=".$_POST['origen'];

//realizo la consulta paro obtener los totales
//echo $where;
$tabla1="sucursales";
$condicion1=" ".$where;
$orden1=" order by  sucursalId asc ";
$result1=  cons_sql($tabla1, $condicion1, $orden1);
//finc consulta

$pages->items_total = mysql_num_rows($result1);
$pages->mid_range = 9;
$pages->paginate();
$tabla="sucursales";
$condicion=" ".$where;
$orden=" order by sucursalId asc ".$pages->limit;
$result=  cons_sql($tabla, $condicion, $orden);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sistema de Registro de Atencion</title>

<link href="estilos.css" rel="stylesheet" type="text/css" />

<!--libreria jquery central-->

<script src="jquery-ui/js/jquery-1.9.1.js"></script>
<!--fin libreria central-->

<!--Librerias para el combo-->
<script language="JavaScript" type="text/javascript" src="combos/jquery.chainedSelects.js"></script>
<!--fin libreria-->

<!--librerias ui-->
<link href="jquery-ui/css/ui-lightness/jquery-ui-1.10.2.custom.css" rel="stylesheet"/>
<script src="jquery-ui/js/jquery-ui-1.10.2.custom.js"></script>
<!--fin libreria-->
<!--libreria flexigrid-->
<link rel="stylesheet" type="text/css" href="jquery-ui/css/ui-flexigrid/flexigrid.css">
    <script type="text/javascript" src="jquery-ui/js/flexigrid.js"></script>
<!--fin libreria-->



<script language="JavaScript" type="text/javascript">
$(function()
{

//        funcion que implementa combos
	$('#tipopedido').chainSelect('#estado','combolistado.php',
	{
		before:function (target) //before request hide the target combobox and display the loading message
		{
			$("#loading").css("display","block");
			$(target).css("display","none");
		},
		after:function (target) //after request show the target combobox and hide the loading message
		{
			$("#loading").css("display","none");
			$(target).css("display","inline");
		}
	});
//        fin funcion

//          funcion datapicker

       $( "#fecha" ).datepicker({
         dateFormat: "yy-mm-dd"

      });
       $( "#fechah" ).datepicker({
         dateFormat: "yy-mm-dd"

      });
//             funcion

$( "#chofer" ).autocomplete({
			source: "autoGuias.php"
		});
$( "#patente" ).autocomplete({
			source: "autoPatentes.php"
		});
 $( "#punto" ).autocomplete({
			source: "autoPuntos.php"
		});
$( "#numero" ).autocomplete({
			source: "autoNumeros.php"
		});

  $('#flex1').flexigrid({
      colModel : [
                
		{display: 'Nro.', name : 'guiaID', width : 50, sortable : true, align: 'center'},
		{display: 'Codigo', name : 'fecha', width : 100, sortable : true, align: 'left'},
		{display: 'Nombre', name : 'origen', width : 250, sortable : true, align: 'left'},
		
                {display: 'Acciones', name : 'acciones', width : 90, sortable : false, align: 'left'}
		],
                width: 450,
                height: 1000
              
  });
<?php for ($i=1;$i<30;$i++):?>
  $('#fila<?php echo $i?>').tooltip({
      track: true
    });
 
<?php endfor?>
<?php for ($i=1;$i<30;$i++):?>
  $('#visualizar<?php echo $i?>').tooltip({
      track: true
    });

<?php endfor?>
 <?php for ($i=1;$i<30;$i++):?>
  $('#editar<?php echo $i?>').tooltip({
      track: true
    });

<?php endfor?>
<?php for ($i=1;$i<30;$i++):?>
  $('#imprimir<?php echo $i?>').tooltip({
      track: true
    });

<?php endfor?>
<?php for ($i=1;$i<30;$i++):?>
  $('#tratar<?php echo $i?>').tooltip({
      track: true
    });

<?php endfor?>

	  $( "#menu" ).menu({position: {at: "left bottom"}});
});
</script>



</head>

<body>

<div class="container">
<?php include "includes/head.php"?>
   <div class="content">
       <div class="tituloprincipal"><img src="img/pedidos.jpg" width="25" height="25" border="0"/> Lista de Sucursales / Turnos
        <?php include 'includes/submenu.php';?>  
       </div>
       
       <div class="contenedorpedido">
       <form id="altapedido" name="altapedido" method="POST" action="ListaGuias.php">
        <fieldset>
             <legend><b>Seleccione Filtros</b></legend>
             <table>
                
                 <tr>
                     <td class="textotablamenuform">Sucursal</td>
                     <td class="textotablamenuform" colspan="7">
                        <select name="origen" id="origen" class="campo_form">
                             <option selected value="0">Todos...</option>
                             <?php
                             $ped=obtener_sucursales();

                             while($regPed=mysql_fetch_array($ped)){
                                 
                                       echo "<option value='".utf8_encode($regPed['sucursalId'])."'>".utf8_encode($regPed['sucursalNombre'])." (".utf8_encode($regPed['sucursalCodigo']).")</option>";


                             }

                             ?>

                         </select>
                     </td>
                    
                 </tr>
                
                   <tr>
                    <td class="textotablamenuform" style="text-align: right;" colspan="8">
                         <input type="reset" name="enviar" value="Limpiar"  class="boton_form"/>
                         <input name="submit" id="submit" type="submit" value="Realizar Busqueda" class="boton_form"/>
                     </td>
                 </tr>
             </table>
        </fieldset>
       </form>
           <fieldset>
             <legend><b>Resultado de la Busqueda</b></legend>
             
             </br>

             <table id="flex1">

               <tbody>

                <?php
                $i=1;
                if($pages->items_total >0)
                while($reg=  mysql_fetch_array($result)):?>
                  <tr id="fila<?php echo $i?>" >
                     
                     <td><?php echo $reg['sucursalId']?></td>
                     <td><?php echo $reg['sucursalCodigo']?></td>
                     
                     <td ><?php echo utf8_encode($reg['sucursalNombre'])?></td>
                     
                     <td>
                     <a href="verTurno.php?suc_id=<?php echo $reg['sucursalId']?>&suc_nombre=<?php echo $reg['sucursalNombre']?>" ><img src="img/turnos.jpg" border="0" width="25px" id="visualizar<?php echo $i?>" title="Visualizar Turnos"></a>
                     </td>
                 </tr>
                 <?php
                 $i++;
                 endwhile
                
                 ?>

                   <tr>
                       <td colspan="8"><?php echo $pages->display_jump_menu();echo $pages->display_items_per_page();echo $pages->display_pages() ?></td>
                   </tr>
                </tbody>

             </table>
             

        </fieldset>
           
       </div>
 
       <div class="clear"></div>
   <br>
   </div>
  <?php include "includes/pie.php"?>
  
</div>
</body>
</html>
